<include file="Public/header" />
<title></title>
</head>
<body>
<div class="page-container">
    <form class="form form-horizontal" id="form-article-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账册名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<{$result.name}>" placeholder=""  name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账册编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<{$result.book_no}>" placeholder=""  name="book_no">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账册类型：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="type" data-toggle="<{$result.type}>" class="select">
                    <option value="0">---请选择---</option>
                    <option value="1">一般账册</option>
                    <option value="2">跨境账册</option>
                </select>
				</span>
            </div>
        </div>
		<div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商家编码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="<{$result.merchant_code}>" placeholder=""  name="merchant_code">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button onClick="save('<{$result.id}>')" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
                <button onClick="cancel()" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
<include file="Public/footer_js" />
<script>
    $("select[name=type]").prop('value',$("select[name=type]").attr('data-toggle'));
    function save(id){
		merchant_code=$("input[name=merchant_code]").val();
		if(merchant_code.length!=11){
			layer.msg('商家编码必须为11位！');
			return false;
		}
		if(merchant_code.substr(0,1)!='P' && merchant_code.substr(0,1)!='C'){
			layer.msg('商家编码必须以C或P开头！');
			return false;
		}
        $.post('__CONTROLLER__/editD',{
            id:id,
            name:$("input[name=name]").val(),
            book_no:$("input[name=book_no]").val(),
			merchant_code:$("input[name=merchant_code]").val(),
            type:$("select[name=type]").val(),
        },function (msg){
            layer.msg(msg.data);
            if(msg.flag==1){
                setTimeout(function (){
                    parent.layer.closeAll();
                    parent.location.reload();
                },800);
            }
        },'json');
    }
    function cancel(){
        parent.layer.closeAll();
    }
</script>
</body>
</html>